/**
 * Created with JetBrains WebStorm. User: Administrator Date: 13-11-11 Time: 上午10:06 To change this template use File |
 * Settings | File Templates.
 */
Ext.define("byb.view.window.UserLoginWindow", {
    extend: "Ext.container.Viewport",
    alias: "widget.userLoginWindow",
    renderTo: document.body,
    border: false,
    autoShow: true,
    initComponent: function() {
        var formItemDefaults = {
            labelAlign: 'right',
            labelWidth: 60,
            allowBlank: false,
            listeners: {
                scope: this,
                specialkey: function(field, e) {
                    if (e.getKey() === e.ENTER && this.handler) {
                        this.handler.call(this.scope);
                    }
                }
            }
        };
        this.items = [{
            xtype: 'container',
            cls: 'login-top'
        }, {
            xtype: 'container',
            cls: 'login-bottom',
            items: [{
                xtype: 'form',
                cls: 'login-bar',
                layout: {
                    type: 'hbox',
                    align: 'middle'
                },
                defaults: formItemDefaults,
                defaultType: 'textfield',
                fieldDefaults: {
                    labelAlign: 'left',
                    labelWidth: 40,
                    margin: '0 0 0 10px'
                },
                items: [{
                    labelWidth: 50,
                    fieldLabel: '用户名',
                    name: 'j_username',
                    emptyText: '请输入用户名...'
                }, {
                    labelWidth: 40,
                    xtype: 'textfield',
                    inputType: 'Password',
                    fieldLabel: '密码',
                    name: 'j_password'
                }, {
                    labelWidth: 50,
                    fieldLabel: '验证码',
                    name: 'j_randcode',
                    emptyText: '请输入验证码...',
                    allowBlank: false 
                }
                ,{
            	    xtype: 'container', //或者xtype: 'component',  
            	    html : '<div style="padding-top:3px;"><img alt="如果看不清单击图片更换图片。" '
            	    	+'id="randcodeImg" height="22" width="75" src="'
            	    	+byb.Constant.RandCodeURL+'" mce_src="validateCodeServlet" border=0></img></div>'
	                , listeners: {
	                    click: {
	                        element: 'el', 
	                        fn: function(){
	                        	Ext.getDom('randcodeImg').src=byb.Constant.RandCodeURL+'?'+(new Date().getTime());
	                        }
	                    }
	                }
                }  
                ,{
                    xtype: 'button',
                    action: 'login',
                    text: '登录',
                    style: 'margin:5px;',
                    formBind: true,
                    handler: this.handler || Ext.emptyFn,
                    scope: this.scope || this
                }]
            }]
        }];
        this.callParent(arguments);
    }
});
